﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using NativeCode.Core.Data.Attributes;

namespace SampleWebApp
{
	[Filterable]
	[DataContract, Serializable]
	public class Customer
	{
		/// <summary>
		/// Example property that demonstrats that decorating with both Filterable and NotFilterable,
		/// NotFilterable always wins.
		/// </summary>
		[Filterable]
		[NotFilterable]
		[DataMember]
		public Guid Id { get; set; }

		[Filterable]
		[DataMember]
		public int BirthYear { get; set; }

		[Filterable]
		[DataMember]
		public string FirstName { get; set; }

		[Filterable]
		[DataMember]
		public string LastName { get; set; }

		[Filterable]
		public string FullName
		{
			get { return string.Format("{0} {1}", FirstName, LastName); }
		}

		[Filterable]
		[DataMember]
		public string PhoneNumber { get; set; }

		[Filterable]
		[DataMember]
		public string ZipCode { get; set; }

		public static IQueryable<Customer> Samples()
		{
			Random random = new Random();
			return (new List<Customer>
			{
				new Customer
				{
					Id = Guid.NewGuid(),
					BirthYear = random.Next(1970, 1990),
					FirstName = "Mike",
					LastName = "Pham",
					PhoneNumber = "313-555-0869",
					ZipCode = "19380",
				},
				new Customer
				{
					Id = Guid.NewGuid(),
					BirthYear = random.Next(1970, 1990),
					FirstName = "Dryplo",
					LastName = "Efo",
					PhoneNumber = "313-555-0869",
					ZipCode = "19380",
				},
				new Customer
				{
					Id = Guid.NewGuid(),
					BirthYear = random.Next(1970, 1990),
					FirstName = "Angie",
					LastName = "Sanchez",
				},
				new Customer
				{
					Id = Guid.NewGuid(),
					BirthYear = random.Next(1970, 1990),
					FirstName = "T",
					LastName = "G",
					PhoneNumber = "313-555-0869",
					ZipCode = "19380",
				},
			}).AsQueryable();
		}
	}
}